
function getTimeAdoen(timeAdorn, name, def) {
	if (timeAdorn[name])
		return timeAdorn[name]
	return timeAdorn[def]
}


export default {
	getCurrentTime(data) {

        let {type,timeAdorn} = data || {}
		if(timeAdorn == null)
			timeAdorn ={
				bigDefault: "/",
				smallDefault: ":"
			}
		const now = new Date();

		const year = now.getFullYear() + getTimeAdoen(timeAdorn, 'year', 'bigDefault');
		const month = ('0' + (now.getMonth() + 1)).slice(-2) + getTimeAdoen(timeAdorn, 'month', 'bigDefault');
		const day = ('0' + now.getDate()).slice(-2) + " ";
		const hours = ('0' + now.getHours()).slice(-2) + getTimeAdoen(timeAdorn, 'hours', 'smallDefault');
		const minutes = ('0' + now.getMinutes()).slice(-2) + getTimeAdoen(timeAdorn, 'min', 'smallDefault');
		const seconds = ('0' + now.getSeconds()).slice(-2) ;



		if (type == null || type == 'common')
			return year + month + day + hours + minutes + seconds;



	},
	
	getCurrentTimeStamp(){
		return Date.parse(new Date())
	},
	
	isCurrentExpire(oldTimeStamp,expireTime){
		let nowTimeStamp =  Date.parse(new Date())
		return nowTimeStamp - oldTimeStamp > expireTime
	},
	
	isExpire(nowTimeStamp,oldTimeStamp,expireTime){
		return nowTimeStamp - oldTimeStamp > expireTime
	}
}